package cn.com.fig.filter;

import cn.com.fig.portal.AccessFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Order(1)
@WebFilter(filterName = "myFilter", urlPatterns = "/*",initParams={
        @WebInitParam(name = "NOVALIDATE_SESSION", value = "/login.html,/LoginControl/login,/LoginControl/clientCheck,/LoginControl/logout,/images/,/js/,/favicon.ico"),
        @WebInitParam(name = "TOKEN_VALIDATE_PATH", value = "/LoginControl/clientCheck"),
        @WebInitParam(name = "LOGIN_PATH", value = "/login.html")
})
public class MyFilter extends AccessFilter {
    @Value("${sso.server.url}")
    protected String ssoUri;

    @Override
    public void init(FilterConfig fc) throws ServletException {
        super.ssoUri = this.ssoUri;
        super.init(fc);
    }
    @Override
    public boolean validateAccessUrlPremission(HttpServletRequest req, HttpServletResponse res) {
        return true;
    }

    @Override
    public void initSession(HttpServletRequest req, HttpServletResponse res) {

    }

    @Override
    public void destroy() {

    }
}
